package top.forforever.srb.oss.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import top.forforever.srb.common.result.R;
import top.forforever.srb.oss.service.OssService;

/**
 * @create: 2023/5/4
 * @Description:
 * @FileName: OssController
 * @自定义内容：
 */
@RestController
@RequestMapping("/api/oss/file")
public class OssController {

    @Autowired
    private OssService ossService;

    @PostMapping("uploadImage")
    public R uploadImage(@RequestParam("file")MultipartFile multipartFile,String module) {
        String imageUrl = ossService.uploadImage(multipartFile,module);
        return R.ok().data("imageUrl",imageUrl);
    }

    @DeleteMapping("deleteImage")
    public R deleteImage(String url) {
        ossService.deleteImage(url);
        return R.ok();
    }

    @GetMapping("testSentinel")
    public R testSentinel() {
        return R.ok();
    }


}
